from flask import Blueprint
from flask import redirect
from flask import request
from flask import session
from flask import url_for

admin_blu = Blueprint("admin", __name__)

from . import views


@admin_blu.before_request
def cheak_admin():
    # 若不是管理员直接跳转到主页
    is_adnin = session.get("is_admin", False)
    if not is_adnin and not request.url.endswith(url_for('admin.login')):
        return redirect('/')